﻿var XEditor;
var EditorWindow;
var EditorWindow=getEditorWindow();
var dialogargment=EditorWindow.$dialog.Argment;
var EditorPath=EditorWindow.location.toString().replace("editor.htm","");
XEditor=EditorWindow.XEditor;
EditorWindow.renderWindowAsIE(window);


//加载语言
//document.getElementById("scriptlanguage").src="../script/"+EditorWindow.WebNoteLanguage+".js";
//加载样式


//加载样式
window.onbeforeunload=function()
{
	dialogargment=null;
}

function getEditorWindow()
{
	var iframes;
	iframes=window.top.document.getElementsByTagName("iframe");
	for (i=0;i<iframes.length;i++)
	{
		if (iframes[i].contentWindow.location.toString().indexOf("editor.htm")>0)
		{
			return iframes[i].contentWindow;
		}
	}
}

function dialogOnLoad()
{
	renderControls();
	document.getElementById("BtnOk").focus();
	
	if(!document.createStyleSheet) 
    {
    	//firefox加载
		var cssObj=document.createElement("link"); 
		cssObj.type="text/css";
		cssObj.rel="stylesheet";
		cssObj.href=EditorWindow.document.getElementById("SkinStyleSheet").href;
		document.body.appendChild(cssObj);
		cssObj=null;
    } 
	else
	{
		SkinStyleSheet.href=EditorPath+EditorWindow.document.getElementById("SkinStyleSheet").href;
	}

	document.onkeydown=function(event)
	{
		event=(window.event?window.event:event);
		var keycode=(window.event ? window.event.keyCode : event.which);
		switch (keycode)
		{
			case 27:
				EditorWindow.$dialog.close();
				break;
			case 13:
				if (window.event)
					event.returnValue=false;
				BtnOk_onclick();
				break;
		}
	}
}

function renderControls()
{
	var i,Tags
	Tags=("span,option").split(",");

	for (iTags in Tags)
	{

		var spanControls=document.getElementsByTagName(Tags[iTags]);
		for (i in spanControls)
		{
			
			if (spanControls[i].innerText!="" && typeof(spanControls[i].innerText)!="undefined")
			{
				//alert(spanControls[i].innerText);
				spanControls[i].innerText=EditorWindow.eval(spanControls[i].innerText);
			}
		}
	}
}

function PrintButtons()
{
	document.write("<div class=\"divbuttons\">");
    document.write("<input type=\"button\" value=\""+window.parent.lang_button_ok+"\" id=\"BtnOk\" class=\"sysbtn5\" tabindex=\"-1\" onclick=\"javascript:BtnOK_onclick();\">");
    document.write("</div>");
}

function PrintButtons2()
{
	document.write("<div id=\"divbuttons\">");
    document.write("<input type=\"button\" value=\""+EditorWindow.lang_button_ok+"\" id=\"BtnOk\" class=\"sysbtn5\" onclick=\"javascript:BtnOk_onclick();\">");
	document.write("<input type=\"button\" value=\""+EditorWindow.lang_button_cancel+"\" id=\"BtnCancel\" class=\"sysbtn5\" onclick=\"javascript:BtnCancel_onclick();\">");
	document.write("</div>");
}

function PrintButtons3()
{
	document.write("<div class=\"divbuttons\">");
	document.write("<input type=\"button\" value=\""+window.parent.lang_button_ok+"\" id=\"BtnOk\" class=\"sysbtn5\">");
	document.write("<input type=\"button\" value=\""+window.parent.lang_button_cancel+"\" id=\"BtnCancel\" class=\"sysbtn5\">");
	document.write("<input type=\"button\" value=\""+window.parent.lang_button_apply+"\" id=\"BtnUse\" class=\"sysbtn5\">");
	document.write("</div>");
}

function PrintButtonCss()
{
	document.write("<div id=\"btnCss\"></div>");
}

